<?php // no direct access
defined('_JEXEC') or die('Restricted access');

jimport('mylibs.globalModel');  
$globalModel  = new globalModel();
//$template_dir = $this->baseurl . '/templates/mwc_careitec/assets/'; 
$template_dir = '/templates/mwc_careitec/assets/';

if($_SERVER['HTTP_REFERER'] == '1'){
    $referer = $_SERVER['HTTP_REFERER'];    
}   
else{
    $referer = 'javascript:history.go(-1);';
}    

$menu_id = JRequest::getVar('Itemid', 0, 'get');
$cat_id = JRequest::getVar('category_id', -1, 'get');
$layout = JRequest::getVar('layout', 0, 'get');
$current_id = JRequest::getVar('id', 0, 'get');  

$menus = &JSite::getMenu();                                             
$menu  = $globalModel->getMenu($menu_id, 0); 
$ignore = isset($menu->query['id']) ? $menu->query['id'] : -1;    

$title = $menu->name;
$doc =& JFactory::getDocument();
$doc->setTitle($title);   
?>

<div id="main" class="p15t"> 
    <div class="w214 float_left">
        <!-- Menu -->
        <?php if(1==0){ ?>
        <div class="w214 left_menu m10b"> 
            <div class="left_menu">
                <ul class="parent_menu">    
                    <li class="curr_left_menu">
                        <a href="javascript:void(0);"><?php echo $menu->name; ?></a> 
                        <ul class="child_menu">                                
                            <?php 
                            $layout = $layout ? '&layout=' . $layout : '';
                            if(isset($sec_id)){
                                $sub_menu = $globalModel->getContentItems($sec_id, $cat_id, $ignore);
                            }
                            else{
                                $sub_menu = $globalModel->getContentByCategory($cat_id, $ignore);
                            }
                            foreach($sub_menu as $key => $value ){                                    
                                //$selected = $current_id == $value['id'] ? ' class="active"'   : '';                                
                                $current  = $current_id == $value['id'] ? ' class="curr_sub"' : '';
                                $link = 'index.php?option=com_content&view=article&id=' . $value['id'] . '&category_id=' . $cat_id . '&section_id=' . $sec_id . '&Itemid=' . $menu_id . $layout . '&emulate=1';
                                ?>    
                                <li<?php //echo $selected; ?>>
                                    <a <?php echo $current; ?> href="<?php echo $link; ?>" ><?php echo $value['title'];?></a>
                                </li>                  
                            <?php } ?> 
                        </ul>
                    </li> 
                </ul>
            </div>
            <div class="left_menu_bot"></div>
        </div>
        <?php } ?>
        
        <!-- Book -->
        <div class="w214 po m10b"> 
            <?php $link = $globalModel->getLeftColumnBookLink(); ?>             
            <a href="<?php echo $link; ?>"><img src="<?php echo $template_dir; ?>images/book_banner.png" alt="" /></a>                        
        </div>
        
        <!-- News -->
        <div class="w214">
            <div class="ads_sub_top"></div>
            <div class="ads_sub_mid">
                <div class="w186 mc p10t p10b">
                    <?php                 
                    // Intel Inside   
                    $arr_data2 = $globalModel->getLeftColumnArticle();
                    foreach($arr_data2 as $key => $value){    
                        $text = strip_tags($value['introtext']);
                        $text = strlen($text) > 100 ? mb_substr($text, 0, 100, 'UTF-8') : $text;
                        $link = $globalModel->getLeftColumnArticleLink($value['id']);
                        ?> 
                        <a href="<?php echo $link; ?>"><img src="<?php echo $template_dir; ?>images/banner_ads_sub.jpg" alt="<?php echo $value['title'];?>" /></a>
                        <p class="p5t"><?php echo $text; ?>...<a href="<?php echo $link; ?>"><?php echo JText::_('READ_MORE'); ?></a></p>                            
                    <?php } ?> 
                </div>
            </div>
            <div class="ads_sub_bot"></div>
        </div>
    </div>

    <div class="w708 bg_left_col2 float_right p22l"> 
        <div class="w708 bg_tt_sub1">
            <h2 class="p5t float_left"><?php echo $menu->name; ?></h2>
            <!-- <p class="float_right p5t" style="display:none"><a href="#"><img src="<?php echo $template_dir; ?>images/tilbage_icon.png" alt="" /> Tilbage</a></p> -->
            <br style="clear:both" />
        </div> 
        
        <div class="w708">
            <div class="w708">
                <div class="bord_r_l">
                    <?php              
                    foreach($this->menu_data as $menu_type){
                        if($menu_type['type'] = 'mainmenu'){
                            $main_menu = $menu_type['items'];
                            break;
                        }     
                    }
                                            
                    $no_children = false;
                    foreach($main_menu as $item){ 
                        $class = $no_children ? 'men_site1' : 'men_site';
                        $sub_menu = $globalModel->getChildrenMenu($item->id, 1); 
                        $no_children = empty($sub_menu); 
                    ?>
                        <div class="<?php echo $class; ?>"><?php echo $item->name; ?></div>
                        <?php if(!$no_children){ ?>
                            <div class="p15l p10t p10b"> 
                                <?php foreach($sub_menu as $sub_item){ ?>   
                                    <span class="organ_text">»</span>&nbsp;<?php echo $sub_item['name']; ?><br />
                                <?php } ?>
                            </div>  
                        <?php } ?>                    
                    <?php } ?>
                </div>
            </div>
        </div>   
    </div>
</div>

<div id="footer" class="bg_foot_sub">
    <div class="w950 mc p15t p15b">
        <p class="float_left">Copyright © 2010 <a href="<?php echo $this->baseurl; ?>">CAREITEC.DK</a>. All rights reserved.</p>
        <p class="float_right">Design by <a href="http://www.mywebcreations.dk/" target="_blank">My Web Creations</a></p>
        <br style="clear:both" />
    </div>
</div>
</div>
</div>
